package com.lf.sys.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lf.sys.model.SysUser;
import com.lf.sys.service.UserService;

/**
 * 用户管理类
 */
@Controller
public class UserController {
	@Resource
	private UserService tuserService;
	private Logger logger = LoggerFactory.getLogger(getClass());

	/**
	 * 用户管理跳转
	 */
	@RequestMapping("/userList")
	public String userList(HttpServletRequest request, Model model) {

		return "sysBase/list_UserInfo";
	}

	// 查询全部的用户数据，
	@RequestMapping("/userListAjax")
	@ResponseBody
	public List<SysUser> userListAjax(HttpServletRequest request) {

		String orgid = request.getSession().getAttribute("orgid") + "";
		List<SysUser> userlist = tuserService.listUserInfo(orgid);

		return userlist;
	}

	// 查询全部的用户数据，
	@RequestMapping("/listUserInfoAjax")
	@ResponseBody
	public List<SysUser> listUserInfoAjax(HttpServletRequest request) {
		String orgid = request.getSession().getAttribute("orgid") + "";
		logger.info("--------------------------------------------------" + orgid);
		List<SysUser> userInfo = tuserService.listUserInfo(orgid);

		return userInfo;
	}

	// user添加
	@RequestMapping("/add_userInfo")
	public String addUserInfo() {

		return "sysBase/add_userInfo";
	}

	// 删除
	@RequestMapping("/deleteUserByid")
	@ResponseBody
	public String deleteUserByid(HttpServletRequest request) {
		String id = request.getParameter("id");

		String str = tuserService.deleteUserByid(id);
		return str;
	}

}
